package ear;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

public class PatientServiceImpl implements PatientService{

    /*
     * The Entity Manager, responsible for the operations with the database.
     */
    @PersistenceContext
    private EntityManager em;

	
	public PatientServiceImpl () {
		//Constructor default
	}
	
	public Integer createPatient (String name, String email) {
		Patient patient = new Patient(name,email);
		return save(patient);
	}
	
	
    @Override
    public Integer save(Patient patient) {
            em.persist(patient);
            return patient.getId();
    }

}
